package top.lcm889.juc.demo;

/**
 * @author Coder-lcm
 * @date 2021/4/10
 */
public class TestRunnable implements Runnable{

    private int count = 200;

    @Override
    public void run() {
        while (count > 0){
            /**
             * 实现Runnable接口的方式，创建线程，没法直接调用Thread.getName()
             */
            System.out.println(Thread.currentThread().getName() + " : " + count--);
        }
    }

    public static void main(String[] args) {
        TestRunnable runnable = new TestRunnable();
        Thread thread1 = new Thread(runnable, "Thread-A");
        thread1.start();
        System.out.println(thread1.isAlive());
        Thread thread2 = new Thread(runnable, "Thread-B");
        thread2.start();
        System.out.println(thread2.isAlive());
        Thread thread3 = new Thread(runnable, "Thread-C");
        thread3.start();
        System.out.println(thread3.isAlive());
        Thread thread4 = new Thread(runnable, "Thread-D");
        thread4.start();
        System.out.println(thread4.isAlive());
        Thread thread5 = new Thread(runnable, "Thread-E");
        thread5.start();
        System.out.println(thread5.isAlive());
        Thread thread6 = new Thread(runnable, "Thread-F");
        thread6.start();
        System.out.println(thread6.isAlive());
        Thread thread7 = new Thread(runnable, "Thread-G");
        thread7.start();
        System.out.println(thread7.isAlive());

    }
}
